/*=====================================================================================================================
 * 
 * Repository path:     $HeadURL: http://sstu.googlecode.com/svn/trunk/src/include/triac_control.h $
 * Last committed:      $Revision: 32 $
 * Last changed by:     $Author: vladislav.gyurov@gmail.com $
 * Last changed date:   $Date: 2014-03-10 19:38:23 +0000 (Mon, 10 Mar 2014) $
 * ID:                  $Id: triac_control.h 32 2014-03-10 19:38:23Z vladislav.gyurov@gmail.com $
 *
 *===================================================================================================================*/
#ifndef TRIAC_CONTROL_H
#define TRIAC_CONTROL_H
    
/*----------------------------------------------------------------------------*/
/* Included files to resolve specific definitions in this file                */
/*----------------------------------------------------------------------------*/
#include "basedef.h"
#include "task.h"

/*----------------------------------------------------------------------------*/
/* Constant data                                                              */
/*----------------------------------------------------------------------------*/
#define TRIAC_FIRE_TIME                (2000ul/T1_TIME)            //triac fire time in task1 periods

/*----------------------------------------------------------------------------*/
/* Exported type                                                              */
/*----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------*/
/* Exported data                                                              */
/*----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------*/
/* Constant exported data                                                     */
/*----------------------------------------------------------------------------*/

/*----------------------------------------------------------------------------*/
/* Exported Macros                                                            */
/*----------------------------------------------------------------------------*/
/* Triac control */
#define _FIRE_TRIAC()(                    \
{                                        \
    pinTH_FIRE = 1;                        \
    _set_triac_state(1);                \
    _set_over_prot_triac_state(1);        \
})    

#define _TRIAC_OFF()(                    \
{                                        \
    pinTH_FIRE = 0;                        \
    _set_triac_state(0);                \
})    

#define _TRIAC()                        pinTH_FIRE



/*----------------------------------------------------------------------------*/
/* Exported functions                                                           */
/*----------------------------------------------------------------------------*/
void triac_fire_timer(void);
void triac_control_init(void);

#endif /* TRIAC_CONTROL_H */
